window.onload = function() {
	/* 留言板缩放效果 */
	document.getElementById("news-css-message-button").onclick = function() {
		var obj = document.getElementById("news-css-message-board");
		obj.style.display = "none";
	};
	document.getElementById("news-css-message-buttons").onclick = function() {
		var obj = document.getElementById("news-css-message-board");
		obj.style.display = "block";
	};
	document.getElementById("news-css-service").onclick = function() {
		var obj1 = document.getElementById("news-css-message-board");
		var obj2 = document.getElementById("news-css-message-board-reduce");
		var obj3 = document.getElementById("news-css-message-board-center");
		obj1.style.display = "none";
		obj2.style.display = "none";
		obj3.style.display = "block";
	};
	document.getElementById("news-css-message-buttonss").onclick = function() {
		var obj1 = document.getElementById("news-css-message-board");
		var obj2 = document.getElementById("news-css-message-board-reduce");
		var obj3 = document.getElementById("news-css-message-board-center");
		obj1.style.display = "none";
		obj2.style.display = "block";
		obj3.style.display = "none";
	};
	/* 验证消息框是否为空 */
	// var i = 0;
	// $("#news-css-message-board-send-button").click(function(event){
	// 	    i++;
	// 		if ($("#news-css-message-board-input-world").val() == "") {
	// 			event.preventDefult();
	// 			$("#news-css-message-board-input-world").css(" border-color","red");
	// 			if (i == 1) {
	// 				$("#news-css-message-board-input-world").after(
	// 					'<p class="Pro-temp" style = "mangin:0 0 -5px 10px; color:#f00; font-size:12px;">留言内容不可为空!</p>');
	// 			}
	// 			}else if ($("#news-css-message-board-input-number").val() == ""){
	// 			 event.preventDefult();
	// 			$("#news-css-message-board-input-number").css(" border-color","red");
	// 			if (i == 1) {
	// 				$("#news-css-message-board-input-number").after(
	// 					'<p class = "Pro-temp" style = "mangin:1px 0 -5px 10px; color:#f00;font-size:12px;">电话不能为空!</p>');
	// 			}
	// 			}
	// })

	/* 导航栏hover效果 */
	$(function() {
		var originalCur = $("#news-css-mainbav li.news-css-mainbav-now-css");
		$("#news-css-mainbav li").mousemove(function() {
			$("#news-css-mainbav li").removeClass("news-css-mainbav-now-css");
			$(this).addClass("news-css-mainbav-now-css");
		});
		$("#news-css-mainbav li").mouseleave(function() {
			$(this).removeClass("news-css-mainbav-now-css");
			originalCur.addClass("news-css-mainbav-now-css");
		});
	});

	// 分页
	var pageBar = new Vue({
		el: '.page-bar',
		data: {
			all: 8, //总页数
			cur: 1 //当前页码
		},
		watch: {
			cur: function(oldValue, newValue) {
				console.log(arguments);
			}
		},
		methods: {
			btnClick: function(data) {
				if (data != this.cur) {
					this.cur = data;
				}
				window.location.href = "news-企业新闻-" + this.cur + ".html";
			},
			pageClick: function() {
				console.log('现在在' + this.cur + '页');
			}
		},
		computed: {
			indexs: function() {
				var left = 1;
				var right = this.all;
				var ar = [];
				if (this.all >= 5) {
					//这里最大范围从3到6，如果到达7，那么下边加2变成9，已经超过最大的范围值
					if (this.cur > 3 && this.cur < this.all - 1) {
						//以4为参考基准，左面加2右边加2
						left = this.cur - 2
						right = this.cur + 2
					} else {
						if (this.cur <= 3) {
							left = 1
							right = 5
						} else {
							right = this.all
							left = this.all - 4
						}
					}
				}
				while (left <= right) {
					ar.push(left)
					left++
				}
				console.log(ar);
				return ar
			}
		}
	})
}
